package com.jokins.admin.ios.user.controller;

import com.jokins.admin.ios.user.param.BookUserChangePasswordParam;
import com.jokins.admin.ios.user.param.BookUserRegisterPasswordParam;
import com.jokins.admin.ios.user.param.BookUserUserLoginParam;
import com.jokins.admin.ios.user.service.BookUserService;
import com.jokins.admin.ios.user.vo.BookUserUserLoginVo;
import com.jokins.common.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 〈〉<br>
 *
 * @author Mr.Wang
 * @create 2025/2/4
 */
@RestController
@RequestMapping("/ios/system")
public class BookUserLoginController {

    @Autowired
    private BookUserService bookUserService;

    @PostMapping("/login")
    public ResultData BookUserUserLogin(@RequestBody BookUserUserLoginParam param) {
        BookUserUserLoginVo sysUserLoginVo = bookUserService.BookUserUserLogin(param);
        Map<String, Object> map = new HashMap<>();
        map.put("sysUserLogin", sysUserLoginVo);
        return new ResultData("登录成功！", map);
    }

    @PostMapping("/changePassword")
    public ResultData BookUserChangePassword(@RequestBody BookUserChangePasswordParam param) {
        bookUserService.BookUserChangePassword(param);
        return new ResultData("密码修改成功！");
    }

    //TODO 注册
    @PostMapping("/register")
    public ResultData BookUserRegisterPassword(@RequestBody BookUserRegisterPasswordParam param) {
        Map<String, String> resultMap = bookUserService.BookUserRegisterPassword(param);
        return new ResultData("注册成功，请等待批准！", resultMap);
    }

    @GetMapping("/rePassword")
    public ResultData BookUserRePassword(String id) {
        String password = bookUserService.BookUserRePassword(id);
        return new ResultData("密码修改成功！", password);
    }
}